import { ViewStyle, ActivityIndicator } from "react-native"

interface Props {
  isLoading?: boolean
  size?: "sm" | "md" | "lg" | "auto"
  style?: ViewStyle
}

export const Loading = (props: Props) => {
  const { isLoading, size = "auto", style } = props
  if (!isLoading) return null

  const $size = {
    sm: 100,
    md: 200,
    lg: 300,
    auto: "100%",
  }

  const $combineStyle: any = {
    ...style,
    width: $size[size || "auto"],
    height: $size[size || "auto"],
  }

  return <ActivityIndicator style={$combineStyle}></ActivityIndicator>
}
